﻿using System;
using Gonte;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MyUtilitiesTest
{
    /// <summary>
    ///This is a test class for ObjectClonerTest and is intended
    ///to contain all ObjectClonerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ObjectClonerTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        [TestMethod()]
        public void ObjectClonerClonePrimitiveTest()
        {
            ObjectToTestPropertyAccessors obj = new ObjectToTestPropertyAccessors();
            obj.Id = Guid.NewGuid();
            obj.Age = 7;
            obj.Date = new DateTime(2002, 5, 25);
            obj.Name = "Sarah";
            obj.Status = ObjectToTestPropertyAccessors.EnumStatus.NotTested;

            ObjectToTestPropertyAccessors cloned = ObjectCloner.Clone<ObjectToTestPropertyAccessors>(obj);
            Assert.AreEqual(cloned.Id, obj.Id);
            Assert.AreEqual(cloned.Age, obj.Age);
            Assert.AreEqual(cloned.Date, obj.Date);
            Assert.AreEqual(cloned.Name, obj.Name);
            Assert.AreEqual(cloned.Status, obj.Status);
        }

        public class CloneableObject
            : ICloneable
        {
            #region ICloneable Members

            public Object Clone()
            {
                return new CloneableObject();
            }

            #endregion
        }

        [TestMethod()]
        public void ObjectClonerCloneICloneableTest()
        {
            CloneableObject obj = new CloneableObject();
            CloneableObject cloned = ObjectCloner.Clone<CloneableObject>(obj);

            //Assert.AreEqual(cloned, obj);
        }

        [TestMethod()]
        public void ObjectClonerCloneValueType()
        {
            int obj = 5;
            int cloned = ObjectCloner.Clone<int>(obj);

            Assert.AreEqual(cloned, obj);
        }
    }
}
